<?php
ob_start();
session_cache_expire(999999999);
if(!isset($_SESSION)) 
{ 
session_start(); 
} 
include '../../operations/connection.php';

if(!isset($_SESSION['user']))
{
	header( 'Location: login.php' );
}
else
{
	$username = $_SESSION['fullname'];
	$id_employee = $_SESSION['IDEmployee'];
}

$idemployee = $_REQUEST['idemployee'];
$pass =strtoupper(md5($_REQUEST['newpassword']));
$repass =$_REQUEST['retypepassword'];
$fulln =$_REQUEST['fulln'];
$employeeCode =$_REQUEST['employeeCode'];
$identity =$_REQUEST['identity'];
$bankName =$_REQUEST['bankName'];
$bankAccount =$_REQUEST['bankAccount'];
$birthday =$_REQUEST['birthday'];
$startwork =$_REQUEST['startwork'];
$endwork =$_REQUEST['startwork'];
$mail =$_REQUEST['mail'];
$mobile =$_REQUEST['mobile'];
$phone =$_REQUEST['phone'];
$address =$_REQUEST['address'];
$position =$_REQUEST['position'];
$currentJob =$_REQUEST['currentJob'];
$description =$_REQUEST['description'];
$department = $_REQUEST['department'];
$roleaccess = $_REQUEST['roleaccess'];
$sex = $_REQUEST['sex'];
$accountant = $_REQUEST['accountant'];
$state = $_REQUEST['state'];
$typeemployee = $_REQUEST['typeemployee'];


	if(isset($_REQUEST['update'])){
		mysql_query("UPDATE `sa_check_time` SET `employeeID`='$employeeCode' 
						WHERE (`employeeID`=(SELECT e.EmployeeCode FROM employee e WHERE e.IDEmployee='$idemployee'));");
		
		$sqlinsert = "Update employee set FullName='$fulln',IDDepartment='$department',IDRole='$roleaccess',Phone='$phone',Birthday='$birthday',Email='$mail',
			Address='$address',Position='$position',Sex='$sex',Accountant='$accountant',
			StartDate='$startwork',CMND='$identity',BankAccount='$bankAccount',BankName='$bankName',
			EmployeeCode='$employeeCode',Mobile='$mobile',EndDate='$endwork',Description='$description',
			CurrentJob='$currentJob',Type_employee ='$typeemployee',state='$state' where IDEmployee='$idemployee'"; 
		mysql_query($sqlinsert);
		
	}else if(isset($_REQUEST['updatePass'])){
		$sqlinsert = "Update employee set Password='$pass' where IDEmployee='$idemployee'" ; 
		mysql_query($sqlinsert);
		
	}
	

mysql_close($connection);


header("Location: ../../employee-broke-admin.php");
ob_flush();


?>